<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function outer() {
            var num = 5;
            //定义一个内部函数
            function inner() {
                //内部函数的返回值是外部函数的一个局部变量
                return num;
            }
            //把局部变量的值++
            num ++;
            // 返回内部函数
            return inner;
        }
        var num = outer()();
        console.log(num);// 6
    </script>
</body>

</html>